<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>closelog</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_001_530">&nbsp;</a>NAME</h4><blockquote>
closelog, openlog, setlogmask, syslog - control system log
</blockquote><h4><a name = "tag_000_001_531">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="syslog.h.html">syslog.h</a>&gt;

void closelog(void);
void openlog(const char *<i>ident</i>, int <i>logopt</i>, int <i>facility</i>);
int setlogmask(int <i>maskpri</i>);
void syslog(int <i>priority</i>, const char *<i>message</i>, ... /* <i>arguments</i> */);
</code>
</pre>
</blockquote><h4><a name = "tag_000_001_532">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i><a href="syslog.html">syslog()</a></i>
function sends a message to an implementation-dependent logging facility, which
may log it in an implementation-dependent system log, write it to the system 
console, forward it to a list of users, or forward it to the logging facility 
on another host over the network.  The logged message includes a message header
and a message body.  The message header contains at least a timestamp and a tag
string.
<p>
The message body is generated from the <i>message</i> and following arguments
in the same manner as if these were arguments to
<i><a href="printf.html">printf()</a></i>,
except that occurrences of %m in the format string pointed to by the
<i>message</i> argument are replaced by the error message string associated
with the current value of <i>errno</i>.  A trailing newline character is added
if needed.
<p>
Values of the <i>priority</i> argument are formed by ORing together a severity
level value and an optional facility value.  If no facility value is
specified, the current default facility value is used.
<p>
Possible values of severity level include:
<dl compact>

<dt>LOG_EMERG<dd>
A panic condition.

<dt>LOG_ALERT<dd>
A condition that should be corrected immediately, such as a corrupted system
database.

<dt>LOG_CRIT<dd>
Critical conditions, such as hard device errors.

<dt>LOG_ERR<dd>
Errors.

<dt>LOG_WARNING<dd>

Warning messages.

<dt>LOG_NOTICE<dd>
Conditions that are not error conditions, but that may require special
handling.

<dt>LOG_INFO<dd>
Informational messages.

<dt>LOG_DEBUG<dd>
Messages that contain information normally of use only when debugging a
program.

</dl>
<p>
The facility indicates the application or system component generating
the message.  Possible facility values include:
<dl compact>

<dt>LOG_USER<dd>
Messages generated by random processes.  This is the default facility
identifier if none is specified.

</dl>
<dl compact>

<dt>LOG_LOCAL0<dd>
Reserved for local use.

<dt>LOG_LOCAL1<dd>Reserved for local use.

<dt>LOG_LOCAL2<dd>Reserved for local use.

<dt>LOG_LOCAL3<dd>Reserved for local use.

<dt>LOG_LOCAL4<dd>Reserved for local use.

<dt>LOG_LOCAL5<dd>Reserved for local use.

<dt>LOG_LOCAL6<dd>Reserved for local use.

<dt>LOG_LOCAL7<dd>Reserved for local use.

</dl>
<p>
The
<i><a href="openlog.html">openlog()</a></i>
function sets process attributes that affect subsequent calls to
<i><a href="syslog.html">syslog()</a></i>.
The
<i>ident</i>
argument is a string that is prepended to every message.  The
<i>logopt</i>
argument indicates logging options.  Values for
<i>logopt</i>
are constructed by a bitwise-inclusive OR of zero or more of the following:
<dl compact>

<dt>LOG_PID<dd>
Log the process ID with each message.  This is useful for identifying specific
processes.

<dt>LOG_CONS<dd>
Write messages to the system console if they cannot be sent to the logging
facility.  
The
<i><a href="syslog.html">syslog()</a></i>
function ensures that the process does not acquire the
console as a controlling terminal in the process of writing the
message.

<dt>LOG_NDELAY<dd>
Open the connection to the logging facility immediately.  Normally the open is
delayed until the first message is logged.  This is useful for programs that
need to manage the order in which file descriptors are allocated.

<dt>LOG_ODELAY<dd>
Delay open until
<i><a href="syslog.html">syslog()</a></i>
is called.

<dt>LOG_NOWAIT<dd>
Do not wait for child processes that may have been created during the
course of logging the message.
This option should be used by processes that enable notification of
child termination using SIGCHLD, since
<i><a href="syslog.html">syslog()</a></i>
may otherwise block waiting for a child whose exit status has already been
collected.

</dl>
<p>
The
<i>facility</i>
argument encodes a default facility to be assigned to all messages that do not
have an explicit facility already encoded.  The initial default facility is
LOG_USER.
<p>
The
<i><a href="openlog.html">openlog()</a></i>
and
<i><a href="syslog.html">syslog()</a></i>
functions may allocate a file descriptor.  It is not necessary to call
<i><a href="openlog.html">openlog()</a></i>
prior to calling
<i><a href="syslog.html">syslog()</a></i>.
<p>
The
<i>closelog()</i>
function closes any open file descriptors allocated by previous calls to
<i><a href="openlog.html">openlog()</a></i>
or
<i><a href="syslog.html">syslog()</a></i>.
<p>
The
<i><a href="setlogmask.html">setlogmask()</a></i>
function sets the log priority mask for the current process to
<i>maskpri</i>
and returns the previous mask.  If the <i>maskpri</i> argument is 0, the
current log mask is not modified.  Calls by the current process to
<i><a href="syslog.html">syslog()</a></i>
with a priority not set in
<i>maskpri</i>
are rejected.  
The default log mask allows all priorities to be logged.
A call to openlog is not required prior to calling
<i><a href="setlogmask.html">setlogmask()</a></i>.
<p>
Symbolic constants for use as values of the <i>logopt</i>, <i>facility</i>,
<i>priority</i>, and <i>maskpri</i> arguments are defined in the
&lt;<b>syslog.h</b>&gt; header.
</blockquote><h4><a name = "tag_000_001_533">&nbsp;</a>RETURN VALUE</h4><blockquote>
The
<i><a href="setlogmask.html">setlogmask()</a></i>
function returns the previous log priority mask.
The
<i>closelog()</i>,
<i><a href="openlog.html">openlog()</a></i>
and
<i><a href="syslog.html">syslog()</a></i>
functions return no value.
</blockquote><h4><a name = "tag_000_001_534">&nbsp;</a>ERRORS</h4><blockquote>
No errors are defined.
</blockquote><h4><a name = "tag_000_001_535">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_001_536">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_001_537">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_001_538">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="printf.html">printf()</a></i>,
<i><a href="syslog.h.html">&lt;syslog.h&gt;</a></i>.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
